<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>登陆-Lily</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/css/admin.css" media="all">
  <link rel="stylesheet" href="/static/css/login.css" media="all">
  <script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>
</head>
<body>
  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>Lily Bearing</h2>
      </div>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
          <input type="text" name="username" id="LAY-user-login-username"  placeholder="用户名" class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
          <input type="password" name="password" id="LAY-user-login-password" placeholder="密码" class="layui-input">
        </div>
       
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid layui-btn-normal" id='login' type='button'>登 陆</button>
        </div>
      </div>
    </div>
    
    <div class="layui-trans layadmin-user-login-footer">
      <p>© 2021 <a href="https://www.lily-bearing.com">lily-bearing.com</a></p>
    </div>
  </div>

<script src="/static/layui/layui.js"></script>  
<script type="text/javascript">
  layui.use('layer', function(){ 
    var $ = layui.jquery, layer = layui.layer; 
  })
  $("#login").click(function(){
    layer.load();
    var username=$.trim($("input[name='username']").val());
    var password=$.trim($("input[name='password']").val());
    if(username==''){
     layer.closeAll('loading');
     layer.msg('请输入用户名');
     return false;
    }
    if(password==''){
     layer.closeAll('loading');
     layer.msg('请输入密码');
     return false;
    }
    $.post("{:url('Index/login')}",{username:username,password:password},function(res){
        if(res.status=='0'){
          layer.closeAll('loading');
          layer.msg(res.msg);
        }
        if(res.status=='1'){
          layer.closeAll('loading');
          layer.msg(res.msg,{
            time: 1500 
          }, function(){
            window.location.href="/admin/index/home.html?nav=console-index";
          });
        }
    })
 })
 //键盘事件
 $(document).keyup(function(event){
  if(event.keyCode ==13){
    $("#login").trigger("click");
  }
 });
</script>
</body>
</html>